package com.zmzncs.lmtc.module.promotion.pojo.month_rule;

import com.zmzncs.lmtc.common.util.ExceptionUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author 任建波
 * @since 2020-08-12
 */
@Data
public class MonthRuleUpdateForm implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id", required = true)
    @NotNull
    private Long id;

    @ApiModelProperty(value = "规则名称", required = true)
    @NotBlank
    private String ruleName;

    @ApiModelProperty(value = "描述")
    private String remark;

    @ApiModelProperty(value = "停车场id", required = true)
    private List<Long> parkIds;

    @ApiModelProperty(value = "月付金额")
    private BigDecimal monthAmount;

    @ApiModelProperty(value = "季付金额")
    private BigDecimal quarterAmount;

    @ApiModelProperty(value = "年付金额")
    private BigDecimal yearAmount;

    @ApiModelProperty(value = "是否所有停车场（1：是，0否）", required = true)
    @NotNull
    private Integer ifAllParks;

    public void validate(){
        //  当选择部分停车场时，parkIds不能为空
        if(ifAllParks.equals(2)){
            ExceptionUtil.paramException("当选择部分停车场时，parkIds不能为空");
        }
        //  校验ifAllParks
        if(!(ifAllParks.equals(0) || ifAllParks.equals(1))){
            ExceptionUtil.paramException("ifAllParks取值范围（1：是，0否）");
        }
        //  校验支付金额
        if(monthAmount == null && quarterAmount == null && yearAmount == null){
            ExceptionUtil.paramException("收费标准必须选一个");
        }
    }

}
